<template>
  <div id="loginLogTable"> 
    <el-table
      :data="tableData"
      stripe
      height="65vh"
      :header-cell-style="{'text-align':'center'}"
      :cell-style="{'text-align':'center'}"
      style="width: 100%;overflow-x: hidden;">
      <el-table-column
        prop="id"
        label="序号">
      </el-table-column>
      <el-table-column
        prop="username"
        label="用户名">
      </el-table-column>
      <el-table-column
        prop="ip"
        label="IP地址">
      </el-table-column>
      <el-table-column
        prop="loginTime"
        :formatter="bms_long"
        label="登录时间">
      </el-table-column>
      <el-table-column
        prop="status"
        label="登录状态">
        <template slot-scope="scope">
          <span v-if="scope.row.status === true">登录成功</span>
          <span v-if="scope.row.status === false">登录失败</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="code"
        label="登录编码">
      </el-table-column>
      <el-table-column
        prop="message.message"
        label="登录描述">
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import tool from '@/assets/js/tool'
export default {
  name: "loginLogTable",
  props: ['tableLoginLogData'],
  mixins: [tool],
  data() {
    return {
      tableData: []
    }
  },
  methods: {
    handleClick(row) {
      this.$emit("showDetail",row)
    },
  },
  watch: {
    tableLoginLogData: {
      deep: true,         // 深度监听
      immediate: false,    // immediate表示在watch中首次绑定的时候，是否执行handler，值为true则表示在watch中声明的时候，就立即执行handler方法，
      handler(newValue,oldValue) {
        this.tableData = newValue
        this.$emit('changeLoad',false)
      }
    },
  }
}
</script>

<style scoped lang="scss">

</style>
